<template lang="html">
  <div class="main-page" id="store-page">
    <!-- 标题 -->
    <!-- <van-nav-bar class="main-header" title="优惠券中心" :left-arrow="true" :fixed="true" :z-index="11" @click-left="onClickLeft"/> -->
    <nav-bar :title="'万券齐发'"  @goBack="onClickLeft"/>

    <!-- 主体内容 -->
      <div class="main-content has-header-space">
        <div class="coupon_grant">
          <div class="coupon_grant_title">
            <h3>选购任意一款尊享礼包</h3>
            <p>即可领取超值满减券</p>
          </div>
          <div class="coupon_list coupon_grant_page">
            <van-list v-model="loading" error-text="请求失败，点击重新加载" @load="onLoad()" loading-text="正在加载中" :finished="finished">
              <item v-for="(item,key) in list" v-bind:key="key" :item="item"></item>
            </van-list>
            <!-- <NotData /> -->
          </div>
        </div>
      </div>
  </div>
</template>

<script>
// import NotData from '@/components/global/not-data.vue'
import Item from '@/components/active/coupon_grant/item.vue'
import NavBar from '@/components/global/nav-bar.vue'
// import Tool from '@/utils/tool.js'

export default {
  components: { Item, NavBar },
  data () {
    return {
      list: [],
      page: 0,
      finished: false,
      loading: true
    }
  },
  created () {
    this.getList()
  },

  methods: {
    onClickLeft () {
      this.$router.go(-1)
    },
    onLoad () {
      this.page = this.page + 1
      this.getList()
    },
    getList () {
      return new Promise((resolve, reject) => {
<<<<<<< HEAD
        this.$Axios({ url: 'product', params: { is_gift_bag: 1 }, method: 'get' }).then((resp) => { // 请求成功
=======
        this.$Axios({ url: 'product', params: { is_gift_bag: 1, page: this.page }, method: 'get' }).then((resp) => { // 请求成功
>>>>>>> v2
          if (resp.return_code === '0000') {
            this.list = this.list.concat(resp.data.list)
            if (resp.data.list.length < 10) {
              this.finished = true
            }
          }
          this.loading = false
          resolve(resp)
        }).catch((error) => { // 请求失败
          this.$_requestInterceptor('error', error)
          reject(error)
        })
      })
    }
  }
}
</script>
